<?php

namespace app\airobot\controller;

use app\airobot\CommonLogic;
use app\airobot\model\BossCommissionPercent;
use app\airobot\model\UserAssetModel;
use app\airobot\model\UserCommission;
use think\admin\Controller;
use think\facade\Db;
use think\Request;

/**
 * 超管系统-用户管理
 * Class UserAction
 * @package app\airobot\controller
 */
class UserAction extends Controller
{
    private $table = 'user_action';
    public $commonLogic;

    /**
     * 用户管理
     * @auth true
     */
    public function index()
    {
        $this->commonLogic = new CommonLogic();
        $userInfo = $this->app->session->get("user");

        $this->title = '用户行为';
        $query = $this->_query($this->table);
        $where = [];
        if (!empty($_GET['user_id'])) {
            $where['user_id'] = $_GET['user_id'];
        }
        $query->where($where);
        $query->order('id asc')->page();
    }

    /**
     * 列表数据处理
     * @auth true
     * @param array $data
     * @throws \Exception
     */
    protected function _index_page_filter(array &$data)
    {
        foreach ($data as &$vo) {
            $vo = $this->dealDecimal($vo);
        }
    }

    public function dealDecimal($data)
    {
        $this->commonLogic = new CommonLogic();
        foreach ($data as $key => $value) {
            if (is_numeric($value)) {
                $data[$key] = $this->commonLogic->DealAmount($value);
            }
        }
        return $data;
    }
}